import java.util.Arrays;

/**
 * @author wangj881
 * @date 2024-11-22 9:30
 */
public class L242_2 {

    public static void main(String[] args) {
        String s = "anagram";
        String t = "nagaram";
        boolean anagram = new Solution().isAnagram(s, t);
        System.out.println(anagram);

    }

    static class Solution {
        public boolean isAnagram(String s, String t) {
            int[] ints = new int[26];
            for (int i = 0; i < s.length(); i++) {
                ints[s.charAt(i) - 'a']++;
            }
            for (int i = 0; i < t.length(); i++) {
                ints[t.charAt(i) - 'a']--;
            }
            for (int val : ints) {
                if (val != 0) {
                    return false;
                }
            }
            return true;
        }
    }

}
